package com.omesoft.hksnore.me;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.omesoft.hksnore.R;
import com.omesoft.hksnore.util.myactivity.MyActivity;
import com.omesoft.hksnore.util.titlebar.MyTitlebarUtil;


/**
 * Created by BigFace on 2017/4/18.
 */
public class AboutActivity extends MyActivity {
    private TextView mVersion_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.snore_activity_about);
        initTitle();
        initView();
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        MyTitlebarUtil.showTitleName(activity, R.string.me_about);
        MyTitlebarUtil.showIbLeft(activity, R.mipmap.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    protected void initView() {
        super.initView();
        mVersion_tv = (TextView) findViewById(R.id.about_version);
        mVersion_tv.setText(getVersion());

    }

    /**
     * 获取版本号
     *
     * @return 当前应用的版本号
     */
    public String getVersion() {
        try {
            PackageManager manager = this.getPackageManager();
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            String version = info.versionName;
            return "当前版本  " + version;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }

    }
}
